#ifndef CCATSETTINGS_H
#define CCATSETTINGS_H

#include <QObject>
#include <QVariantMap>
#include <QSettings>
class CCatSettings : public QObject
{
    Q_OBJECT
public:
    static void setValue(const QString&key,QVariant v)
    {
        Instance()->_config[key]=v;
    }
    static QVariant value(const QString&key){return Instance()->_config[key];}
    static void serialize(const QString&name){
        QSettings(name,QSettings::IniFormat).setValue("config",Instance()->_config);
    }
    static void unserialize(const QString&name){
        QVariantMap map= QSettings(name,QSettings::IniFormat).value("config").toMap();
        for(auto item:map.keys())
        {
            Instance()->setValue(item,map[item]);
        }
    }
signals:

public slots:
protected:
    static CCatSettings*Instance(){if(!_instance)_instance=new CCatSettings;return _instance;}
    static CCatSettings*_instance;
    explicit CCatSettings(QObject *parent = nullptr) : QObject(parent)
    {

    }
private:
    QVariantMap _config;
};

#endif // CCATSETTINGS_H
